<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <p class="my-p"></p>
    <script>
        // 1.创建XMLHttpRequest对象
        const xhr = new XMLHttpRequest()

        // 2.配置请求方法和url地址
        xhr.open('GET', 'http://hmajax.itheima.net/api/province')

        // 3.监听loadend事件，得到响应结果
        xhr.addEventListener('loadend', () => {
            console.log(xhr.response);
            const data = JSON.parse(xhr.response)
            document.querySelector('.my-p').innerHTML = data.list.join('<br>')
        })

        // 4.发起请求
        xhr.send()

    </script>
</body>

</html>